<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script src="../public.js"></script>
<script>
    //三个接口：

    //http://api.k780.com/?app=weather.realtime&weaId=1&ag=today,futureDay,lifeIndex,futureHour&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json

    //http://api.k780.com/?app=idcard.get&idcard=110101199001011114&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json

    //http://api.k780.com/?app=phone.get&phone=13800138000&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json

    //第一个数据请求成功，再请求下一个数据接口。必须采用嵌套。
    //回调函数嵌套的时候，代码的可读性很差。
    //回调地狱


    //采用promise写法
    $ajaxpromise({
        type: 'get',
        url: 'http://api.k780.com/?app=weather.realtime&weaId=1&ag=today,futureDay,lifeIndex,futureHour&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json',
        data: {
            a: 1,
            b: 2,
            c: 3
        },
        async: true
    }).then((data1) => {
        console.log(data1);
        console.log('----------------------------------------------------');
        return $ajaxpromise({
            type: 'get',
            url: 'http://api.k780.com/?app=idcard.get&idcard=110101199001011114&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json',
            data: {
                a: 1,
                b: 2,
                c: 3
            },
            async: true
        })
    }).then((data2) => { //这里的then是上面的then里面的return返回的promise实例。
        console.log(data2);
        console.log('----------------------------------------------------');
        return $ajaxpromise({
            type: 'get',
            url: 'http://api.k780.com/?app=phone.get&phone=13800138000&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json',
            data: {
                a: 1,
                b: 2,
                c: 3
            },
            async: true
        })
    }).then((data3) => {
        console.log(data3);
        console.log('----------------------------------------------------');
        return $ajaxpromise({
            type: 'get',
            url: 'http://api.k780.com/?app=idcard.get&idcard=110101199001011114&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json',
            data: {
                a: 1,
                b: 2,
                c: 3
            },
            async: true
        })
    }).then((data1) => {
        console.log(data1);
        console.log('----------------------------------------------------');
        return $ajaxpromise({
            type: 'get',
            url: 'http://api.k780.com/?app=idcard.get&idcard=110101199001011114&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json',
            data: {
                a: 1,
                b: 2,
                c: 3
            },
            async: true
        })
    }).then((data2) => { //这里的then是上面的then里面的return返回的promise实例。
        console.log(data2);
        console.log('----------------------------------------------------');
        return $ajaxpromise({
            type: 'get',
            url: 'http://api.k780.com/?app=phone.get&phone=13800138000&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json',
            data: {
                a: 1,
                b: 2,
                c: 3
            },
            async: true
        })
    }).then((data3) => {
        console.log(data3);
        console.log('----------------------------------------------------');
    })
</script>